<template>
  <el-form ref="formRef" :model="form" label-width="70px">
    <el-form-item label="学科名" prop="name" required>
      <el-input v-model="form.name" />
    </el-form-item>
    <el-form-item label="归属：" required>
      <el-select v-model="form.level" placeholder="">
        <el-option value="1" label="计算机类"></el-option>
        <el-option value="2" label="管理类"></el-option>
      </el-select>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="submitForm">提交</el-button>
      <el-button @click="resetForm">重置</el-button>
    </el-form-item></el-form
  >
</template>

<script setup>
import { ref } from 'vue'
import { addsubject } from '@/api/subject'
import { ElMessage } from 'element-plus'
const form = ref({
  name: '',
  level: ''
})
const submitForm = async () => {
  console.log(form.value)
  await addsubject(form.value)
  ElMessage({
    message: '学科创建成功',
    type: 'success'
  })
}
const resetForm = () => {
  form.value = {
    name: '',
    level: ''
  }
}
</script>

<style lang="scss" scoped></style>
